///////////////////////////////////////////////////////////////
// Copyright(c) BeingStudio
// 
// FileName : ProgrammingPearls-02-01
// Creator  : ChenShiCai
// E-Mail   : BeingStudio@GMail.com
// Date     : 2008-05-28
// Comment  : 
//
///////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ProgrammingPearls-02-01.h"
#include <cctype>

#ifdef USING_BITMAP
int AddWord(char szWord[], CHANGE_POS_WORD &WordMap) 
{
	int nResult  = false;    
	int nRetCode = false;

    WORD_KRY WordKey;
    unsigned char *pWord = NULL;
    unsigned char ch = 0;
    WORD_LIST *pWordList = NULL;

    PROCESS_ERROR(szWord);

    memset(&WordKey, 0, sizeof(WORD_KRY));
    for (
        pWord = (unsigned char *)szWord, ch = *pWord; 
        ch != '\0'; 
        ++pWord, ch = *pWord
    )
    {   ch = tolower(ch) - 'a';
        WordKey.WordArray[ch >> 1] +=  1 << ((ch & 0x01) << 2);//WordKey[ch / 2] +=  1 << (ch % 2 * 4);       
    } 

    pWordList = &(WordMap[WordKey]);
    pWordList->push_back(szWord);

	nResult = true;
Exit0:
	return nResult;
}

#endif //USING_BITMAP

#ifdef USING_CHAR_ARRAY

#endif//USING_CHAR_ARRAY
